<?php
class Careers_Model extends ORM {
	
	protected $table_name = 'careers';
	protected $primary_key = 'careers_id';
	protected $col_sort_order = 'careers_sort_order';
	protected $col_careers_status = 'careers_status';
	protected $col_count = 'max';
	protected $sorting = array('careers_update_date' => 'desc');
	
	public function get()
	{
		$this->db->from($this->table_name);
		$this->db->select('*');
		$this->db->orderby($this->col_sort_order,'desc');
		$this->db->orderby($this->primary_key,'desc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
	public function count_row()
	{
		$this->db->select('COUNT('.$this->primary_key.') AS '.$this->col_count);
		$this->db->from($this->table_name);
        $this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
	}
	public function get_oder()
	{
		$this->db->from($this->table_name);
		$this->db->select('careers_id');
		$this->db->orderby($this->col_sort_order,'asc');
		$this->db->orderby($this->sorting);
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
	public function get_with_active($language)
	{
		$this->db->select('*');
		$this->db->from($this->table_name);
		$this->db->join('careers_content', 'careers_content.careers_id', 'careers.careers_id');
		$this->db->where('careers_content.languages_id',$language);
		$this->db->where($this->col_careers_status,'1');
		$this->db->orderby('careers.'.$this->col_sort_order,'desc');
		$this->db->orderby('careers.'.$this->primary_key,'desc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
}
?>